<template>
	  <view class="container" >
		  <view class="login-icon" >
			  <image class="login-img" src="@/static/img/login_bg.png"></image>  
		  </view>
		  
		  <view class="login-from" v-if="true">
			  <!-- 头像 -->
			  <view class="people-image">
			  		<image style="margin-left: 229rpx; width: 200rpx;height: 200rpx;" src="@/static/img/login_head.png"></image> 
			  </view>
			  <!--  账号 -->
			  <view class="inputView">
				  <image class="nameImage" src="@/static/ico/zh.png"></image>
				  <input class="inputText" v-model="dlmc" placeholder="请输入登录账号"/>
			  </view>
			  <!-- 密码 -->
			  <view class="inputView">
			  	  <image class="nameImage" src="@/static/ico/mm.png"></image>
			  	   <input class="inputText" v-model="dlmm" password="true"  placeholder="请输入登录密码"/>
			  </view>
 
			  <!-- 登录按钮 -->
			  <view class="loginBtnView" @tap="onLogin">
				  立即登录
			  </view>
		  </view>
	  </view>
</template>
 
<script>
	import utils from '../../common/utils';
	export default {
		data() {
			return {
				phone:"",
				dlmm:"",
				sftc:""
			}
		},
		methods: {
			onClose:function(){
				uni.navigateBack({
					delta: 2,
					animationType: 'pop-out',
					animationDuration: 200
				});
			},onLogin:function(){
				let dlmc = this.dlmc;
				let dlmm = this.dlmm;
				if (dlmc==""){
					this.$utils.toast("请输入登录账号！");
					return;
				}
				if (dlmc==""){
					this.$utils.toast("请输入登录密码！");
					return;
				}
				this.$utils.showLoading("登录中...");
				let data = {
				  dlmc: dlmc,
				  mm:dlmm,
				  timestamp:this.$utils.getTimestamp(),
				};
				this.$myRequest.post(getApp().globalData.loginDoApp,data).then(res => {
					uni.hideLoading();
					console.info(JSON.stringify(res));
					if (res.code==200)
					{
						let a = JSON.parse(utils.decrypt(res.data,"NLfZ3aIOg77E2rT8","0102030405060708"));
						let user = {
							userid:a.c,
							token:a.token,
							aesKey:a.a,
							aesIv:a.b
						}
						console.info("登录信息："+JSON.stringify(user))
						uni.setStorageSync('userInfo',user);
						uni.setStorageSync('isLogin',true);
						if (this.sftc=="1"){
							this.onClose();
						}else{
							//登录成功！
							uni.switchTab({
								url:"/pages/index/index"
							})
						}
					
					}else{
						this.$utils.toast(res.msg);
					}
				}).catch(err => {
					this.$utils.toast(err);
				})
			}
		},onLoad(options) {
			this.sftc=options.sftc;
		},onShow() {
			this.isLogin = utils.checkLogin();
			console.info("获取到的登录状态："+this.isLogin);
			if (this.isLogin){
				uni.switchTab({
					url:"/pages/index/index"
				})
			}else{
				// //弹出登录页面
				// uni.navigateTo({
				// 	url: '/pages/login/login',
				// 	animationType: 'pop-in',
				// 	animationDuration: 200
				// });
			}
		}
	}
</script>
 
<style>
/* #ifndef H5 */
page {
	height: 100%;
	background-color: #eeeeee;
}
/* #endif */
</style>
 
<style lang="scss" scoped>
	page{ 
	 height: 100%; 
	} 
	  
	.container { 
	 height: 100%; 
	 display: flex; 
	 // flex-direction: column;
	 padding: 0; 
	 box-sizing: border-box; 
	 // background-color: #FFFFFF;
	   /*登录图片*/
	   .login-icon{ 
		 height: 100%;
		 .login-img{
		  width: 100%;
		 		position: fixed;
				width: 100%;
				height: 100%;
				top: 0;
				left: 0;
				z-index: -1;
		 } 
	   } 
	   
	   /*表单内容*/
	   .login-from view:nth-child(2){
	   			  margin-top: 148rpx;
	   }
	   .login-from view:nth-child(3){
	   			  margin-top: 42rpx;
	   }
	   .login-from { 
	    margin-top: 168rpx; 
	   	margin-left: 47rpx;
	    position: relative;
	    height:748rpx;
	   	width: 656rpx;
			  people-image{
				 display: flex;
				 flex-direction: column;
				 height:200rpx;
			  }
	   		  .inputView {
	   		   background-color: #FFFFFF; 
	   		   display: flex;
	   		   height: 106rpx;
	   		   border-radius: 6rpx;
	   		   width: 656rpx;
	   		        /*输入框*/
	   			   .nameImage{ 
	   				margin-left: 22rpx; 
	   				margin-top: 40rpx;
	   				width: 24rpx; 
	   				height: 24rpx
	   			   }  
	   			   .inputText {
	   				margin-left: 25rpx; 
	   				margin-top: 32rpx;
	   				color: #727272; 
	   				font-size: 30rpx
	   			   }  
	   		  } 
	   		  .loginBtnView{
	   			  margin-top: 45rpx;
	   			  background: #3399fe;
	   			  text-align: center;
	   			  font-size: 32rpx;
	   			  letter-spacing:4rpx;
	   			  color: #f5ffed;
	   			  height: 106rpx;
				  line-height: 106rpx;
	   			  width: 660rpx;
	   			  border-radius: 6rpx;
	   			  
	   		  }
	   		  
	   		     
	   } 
	} 
</style>
